home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / 134_01.zip / CTOA.H < prev    next >
Text File  |  1993-06-12  |  5KB  |  128 lines

  1. /*    Externals for CTOA: CRL-to-ASM postprocessor.    */
  2.  
  3. /*    Configuration parameters    */
  4.  
  5. #define NAMLEN    33        /* Maximum length of a symbol */
  6. #define MAXEXT    150        /* Maximum number of externals per function */
  7. #define MAXLAB    200        /* Maximum number of relocatable labels per
  8.                    function */
  9. #define MAXEXT    200        /* Maximum number of external variables */
  10. #define MAXAUT    50        /* Maximum number of auto variables per fn */
  11. #define MAXPAR    10        /* Maximum number of formal parameters */
  12.  
  13. #define EXTRNS    0x0115        /* Address of the "extrns" word in C.CCC */
  14.  
  15. /*    Define Scott Layson's CHARIO interface    */
  16.  
  17. #define    CFILE    struct chfile
  18. #define CABS    0        /* Absolute seek */
  19. #define CREL    1        /* Relative seek */
  20. struct chfile {            /* For Scott's CHARIO package */
  21.     int fd;
  22.     int isect;
  23.     int nextc;
  24.     char buff [SECSIZ];
  25.     };
  26.  
  27. /*    Define the opcode table        */
  28.  
  29. struct opc_entry * opctabl ();
  30. struct opc_entry * opc_table;
  31.  
  32. /*    Particular opcodes of interest    */
  33.  
  34. #define    DADB    0x09
  35. #define    DADD    0x19
  36. #define    DADSP    0x39
  37. #define    RET    0xC9
  38.  
  39. /*    Define the CCC symbol table    */
  40.  
  41. struct ccc_entry * ccctabl ();
  42. struct ccc_entry * ccc_table;
  43.  
  44. /*    Define the source file    */
  45.  
  46. char srcfnam [20];        /* Name of the source file */
  47. FILE srcfile;            /* I/O buffer for the source file */
  48. char slopen;            /* Flag = TRUE if part way thru source line */
  49. int sline;            /* Line number relative to function start */
  50. char seof;            /* Flag = TRUE if at EOF in source */
  51. int slevel;            /* Depth of curly-brace nesting in source */
  52. char sname [NAMLEN];        /* Most recent (non-braced) symbol found */
  53. char infunct;            /* Flag = TRUE iff reading a function body */
  54.  
  55. /*    Define the CRL file, and the structure of the CRL directory.    */
  56.  
  57. char crlfnam [20];        /* Name of the .CRL file */
  58. CFILE crlfile;            /* I/O buffer for the .CRL file */
  59. struct {
  60.     char crldtext [512];    /* Function directory in the .CRL file */
  61.     char crleflag;        /* Flag for '-e' option on compile */
  62.     int crleloc;        /* Location specified on '-e' */
  63.     int crlelen;        /* Sixe of external data segment */
  64.     } crldir;
  65.  
  66. /*    Define the CDB file, and the structure of a CDB entry     */
  67.  
  68. char cdbfnam [20];        /* Name of the .CDB file */
  69. CFILE cdbfile;            /* CHARIO buffer for the .CDB file */
  70. struct {
  71.     char cdbname [8];        /* Name of a symbol */
  72.     char cdbflag1, cdbflag2;    /* Symbol attributes */
  73.     unsigned cdbaddr;        /* Address of the symbol */
  74.     unsigned cdbsize;        /* Size of the item */
  75.     unsigned cdb2dim;        /* Second array dimension */
  76.     } cdbentry;
  77. char havecdb;            /* Flag = TRUE iff .CDB file present */
  78. char cdbopen;            /* Flag = TRUE iff .CDB file is now open */
  79. int ncdbents;            /* Number of entries on the CDB file */
  80.  
  81. /*    Define the variable tables: external, auto, parameter     */
  82.  
  83. struct vtabent {
  84.     char vtname [9];    /* Name of a variable */
  85.     unsigned vtaddr;    /* Address of the variable */
  86.     };
  87. struct vtabent extvtab [MAXEXT];    /* External variable table */
  88. int nextvs;                /* Number of external vars */
  89. struct vtabent autvtab [MAXAUT];    /* Auto variable table */
  90. int nautvs;                /* Number of auto vars */
  91. struct vtabent parvtab [MAXPAR];    /* Parameter table */
  92. int nparvs;                /* Number of parameters */
  93.  
  94. /*    Define the characteristics of the function under analysis    */
  95.  
  96. int fnno;            /* Ordinal number of function being processed*/
  97. char fname [NAMLEN];        /* Name of the function being processed. */
  98. unsigned faddr;            /* Seek address of the function extern list */
  99. unsigned ftaddr;        /* Seek address of the function body */
  100. unsigned ftlen;            /* Length of the function body */
  101. char * ftext;            /* The function body, stored in heap storage */
  102. unsigned frlen;            /* Length of the relocation information */
  103. unsigned * freloc;        /* The relocation information, in heap */
  104. unsigned framesize;        /* Stack frame size */
  105. int nexts;            /* Number of external function refs */
  106. char xname [MAXEXT] [NAMLEN];    /* Names of the externals */
  107.  
  108. /*    Working storage for analyzing the function    */
  109.  
  110. char pass1;            /* Flag =TRUE for label pass, FALSE for 
  111.                     content pass */
  112. unsigned locctr;        /* Current location counter */
  113. unsigned highcode;        /* Function's highest jump address */
  114. unsigned retaddr;        /* Function's highest return address */
  115. char opcode;            /* Current opcode being examined */
  116.  
  117. /*    Symbol table for the function under analysis    */
  118.  
  119. struct {
  120.     unsigned lab_val;    /* Relocatable offset for a label */
  121.     char lab_name [8];    /* Name of the label */
  122.     } lab_tab [MAXLAB];
  123. int nlabs;            /* Number of labels in the table */
  124.  
  125. /*    Textword must be declared unsigned in advance of using it.    */
  126.  
  127. unsigned textword ();
  128. t;            /* The function body, store